// client.cpp
#define _WIN32_DCOM
#include <iostream.h>
#include "Component\component.h"

void main()
{
	HRESULT hr;
	cout << "Client: Calling CoInitialize()" << endl;
	CoInitializeEx(NULL, COINIT_MULTITHREADED);
	
	ISum* pSum = 0;
	hr = CoCreateInstance(CLSID_InsideCOM, NULL, CLSCTX_LOCAL_SERVER, IID_ISum, (void**)&pSum);
	if(FAILED(hr))
	{
		cout << "CoCreateInstance FAILED" << endl;
		return;
	}

	cout << "Client:Calling pSum->Sum" << endl;
	int sum;
	pSum->Sum(4, 5, &sum);
	cout << "Client: Sum 4 + 5 = " << sum << endl;
	pSum->Sum(73, 15, &sum);
	cout << "Client: Sum 73 + 15 = " << sum << endl;
	pSum->Sum(24, 35, &sum);
	cout << "Client: Sum 24 + 35 = " << sum << endl;

	pSum->Release();
	CoUninitialize();
}